import { LOGIN, REGISTER } from '../constants/user'

const INITIAL_STATE = {
  phone: '',
  password: ''
}

export default function login (state = INITIAL_STATE, { type, payload }) {
  switch (type) {
    case LOGIN:
      return {
        ...state,
        phone: payload.phone,
        password: payload.password
      }
    case REGISTER:
      return {
        ...state,
        phone: payload.phone,
        password: payload.password
      }
    default:
      return state
  }
}
